﻿ 

using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Reflection;
using zkdao.Application;
using zkdao.Domain;
using sharp_net;
using log4net;

namespace zkdao.Wcf {
	public class RebateService : IRebateService {
		private readonly IRebateService rebateService = IocLocator.Instance.GetImple<IRebateService>();
		public RebateData Get(Guid ID) {
			try {
				return rebateService.Get(ID);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public IEnumerable<RebateData> GetListPager(ref Int32 count, Int32 pageSize, Int32 pageIndex) {
			try {
				return rebateService.GetListPager(ref count, pageSize, pageIndex);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public RebateData Submit(RebateData subInfo, Boolean force, String[] imageIDs, String[] tagIDs) {
			try {
				return rebateService.Submit(subInfo, force, imageIDs, tagIDs);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void Approved(Guid ID) {
			try {
				 rebateService.Approved(ID);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public void Update(RebateData dataObject) {
			try {
				 rebateService.Update(dataObject);
			}
			catch(Exception ex) {
				ILog Log = LogManager.GetLogger("AppService", MethodBase.GetCurrentMethod().DeclaringType);
				Log.Error(ex);
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
	}
}